package com.zhyonk.config;

import com.zhyonk.config.propreties.HtmlToPdf;
import com.zhyonk.util.OsInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

    @Autowired
    HtmlToPdf htmlToPdf;

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        super.addResourceHandlers(registry);
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/images/**").addResourceLocations("file:" + (OsInfo.isWindows()?htmlToPdf.getWindowsOutputImagePath():htmlToPdf.getLinuxOutputImagePath()));
    }
}
